<?php
$today=strtotime(date("Y-m-d",time()));
$dayno=ceil((time()-$today)/300)-1;
if($dayno==0){ //每天前0-5分钟为昨天的最后一期
  $dayno=288;
  $today=strtotime(date("Y-m-d",time()-3600*24));
}

$list=['01','02','03','04','05','06','07','08','09','10'];

shuffle($list);

$num=implode(",",$list);
$expect=date("Ymd",$today)."09".str_pad($dayno,3,0,STR_PAD_LEFT);
$opentime=date("Y/m/d H:i:s",$today+$dayno*300);


$api = "http://api.api861861.com/pks/getLotteryPksInfo.do?issue=&lotCode=10057";
$data = curl_get_content($api);
$data = json_decode($data,1)["result"]["data"];
//var_dump($data["result"]["data"]);
$qh = $data['preDrawIssue'];
$hm = $data['preDrawCode'];
$rq = $data['preDrawTime'];

echo '{"data":[{"gameid":"xyft","opentime":"'.$rq.'","opencode":"'.$num.'","expect":"'.$qh.'"}],"msg":""}';

function curl_get_content($durl){
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $durl);
   curl_setopt($ch, CURLOPT_TIMEOUT, 5);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   $r = curl_exec($ch);
   curl_close($ch);
   return $r;
}